package com.ts.api.module.api.controller;

import com.gitee.apanlh.annotation.viewresolver.RequestParamVo;
import com.gitee.apanlh.util.base.MapUtils;
import com.gitee.apanlh.util.base.StringUtils;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.ts.api.http.receive.biz.ApiReceivePhoneMd5FenLing;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 接入对方文档，额外接口操作
 *
 * @author Pan
 */
@Slf4j
@RestController
@RequestMapping("/data/api/receive/advice")
public class ApiMsgReceiveAdviceController {

    @Autowired
    private ApiReceivePhoneMd5FenLing apiReceiveFenLing;

    /**
     * 纷领-查询授信结果
     *
     * @param apiClientId 请求id
     * @param requestVO   请求参数
     * @return 返回结果
     */
    @PostMapping("/fengling/result/{apiClientId}")
    public Map<String, Object> result(@PathVariable String apiClientId, @RequestParamVo RequestVO requestVO) {
        if (StringUtils.isEmpty(apiClientId)){
            Map<String, Object> resultMap = MapUtils.newLinkedHashMap();
            resultMap.put("code", "500");
            resultMap.put("message", "apiClientId为空");
            log.error("apiClientId为空");
            return resultMap;
        }
        log.info(apiClientId);
        log.info("收到请求：查询授信结果");
        return apiReceiveFenLing.result(requestVO.getBody());
    }

    /**
     * 大麦花回调接口
     * 适配回调地址，无逻辑
     * @return 返回结果
     */
    @PostMapping("/damaihua/result")
    public Map<String, Object> daMaiHuaResult() {
        Map<String, Object> resultMap = MapUtils.newLinkedHashMap();
        resultMap.put("code", "200");
        resultMap.put("msg", "success");
        return resultMap;
    }
}
